package com.my.vertx.udp;

import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.datagram.DatagramSocket;

/**
 * @author: marshal
 * @date: 2023-04-17 16:18
 */
public class VertxUdpClientTest {
    public static void main(String[] args) {
        Vertx vertx = Vertx.vertx();
        DatagramSocket socket = vertx.createDatagramSocket();
        // 处理数据包
        socket
                .handler(packet -> {
                    Buffer data = packet.data();
                    System.out.println("Receive data from udp server : " + data);
                })
                .listen(9601, "127.0.0.1")
                .onComplete(asyncResult -> System.out.println("Receive succeeded? " + asyncResult.succeeded()));


    }
}
